//package com.aabbc.swagger.config;
//
//import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
//import com.google.common.collect.Lists;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.annotation.Order;
//import springfox.documentation.builders.ApiInfoBuilder;
//import springfox.documentation.builders.ParameterBuilder;
//import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.schema.ModelRef;
//import springfox.documentation.service.*;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spi.service.contexts.SecurityContext;
//import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger.web.UiConfiguration;
//import springfox.documentation.swagger.web.UiConfigurationBuilder;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
//
//import java.util.List;
//
///**
// * SwaggerConfig
// *
// * @author: <a href="mailto:chenfenghai@oristartech.com">chenfenghai</a>
// * @version: 1.0
// * @date: 2019-11-25 13:43
// */
//@Configuration
//@EnableSwagger2
//@EnableSwaggerBootstrapUI
//public class Swagger2Config {
//
//    @Bean
//    public UiConfiguration uiConfiguration(){
//        return UiConfigurationBuilder.builder().supportedSubmitMethods(new String[]{})
//                .displayOperationId(true)
//                .build();
//    }
//
//    @Bean(value = "defaultApi")
//    @Order(value = 4)
//    public Docket defaultApi(){
//        return new Docket(DocumentationType.SWAGGER_2)
//                .apiInfo(apiInfo())
//                .select()
//                .apis(RequestHandlerSelectors.basePackage("com.aabbc.swagger"))
//                .paths(PathSelectors.any())
//                .build()
//                .globalOperationParameters(parameters())
//                .securityContexts(Lists.newArrayList(securityContext()))
//                .securitySchemes(Lists.<SecurityScheme>newArrayList(apiKey()));
//    }
//
//    /**
//     * 额外添加的请求头信息
//     * @return
//     */
//    private List<Parameter> parameters(){
//        Parameter parameter1 = new ParameterBuilder()
//                .name("token").description("token令牌").modelRef(new ModelRef("String"))
//                .parameterType("header")
//                .required(false).build();
//        return Lists.<Parameter>newArrayList(parameter1);
//    }
//
//    private ApiInfo groupApiInfo(){
//        return new ApiInfoBuilder()
//                .title("swagger-bootstrap-ui")
//                .description("<div style='font-size:14px;color:red;'>swagger-bootstrap-ui-demo RESTful APIs</div>")
//                .termsOfServiceUrl("http://127.0.0.1:6019/")
//                .contact("fecean@qq.com")
//                .version("1.0")
//                .build();
//    }
//
//
//    private ApiInfo apiInfo(){
//        return new ApiInfoBuilder()
//                .title("swagger-bootstrap-ui RESTful APIs")
//                .description("swagger-bootstrap-ui")
//                .termsOfServiceUrl("http://127.0.0.1:6019/")
//                .contact(new Contact("fecean","http://127.0.0.1:6019/","fecean@qq.com"))
//                .version("1.0")
//                .build();
//    }
//
//    private ApiKey apiKey(){
//        return new ApiKey("BearerToken", "Authorization", "header");
//    }
//
//    private SecurityContext securityContext(){
//        return SecurityContext.builder()
//                .securityReferences(defaultAuth())
//                .forPaths(PathSelectors.regex("/.*"))
//                .build();
//    }
//
//    private List<SecurityReference> defaultAuth(){
//        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
//        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
//        authorizationScopes[0] = authorizationScope;
//        return Lists.newArrayList(new SecurityReference("Authorization", authorizationScopes));
//    }
//}
